package com.itheima.service.Impl;

import com.itheima.Mapper.LoginMapper;
import com.itheima.pojo.Class;
import com.itheima.pojo.User;
import com.itheima.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.awt.print.Book;
import java.util.List;

@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private LoginMapper loginMapper;

    @Override//根据mobile查询user,判断是否是教师
    public User SelectByMobile(String mobile) {
        User user = loginMapper.SelectByMobile(mobile);
        return user;
    }

    @Override//查询ks_class
    public List<Class> SelectClass() {
        List<Class> classes = loginMapper.SelectClass();
        return classes;
    }

    @Override//判断登录
    public User SelectByMobileAndName(User user) {
        User user1 = loginMapper.SelectByMobileAndName(user);
        if(user1!=null){
            String class_id = user.getClassId();
            System.out.println("班级名"+class_id);
            int id = user1.getId();
            System.out.println("id名"+id);
            int i = loginMapper.updateClassIdByUserId(class_id, id);
            System.out.println("返回值"+i);
        }
        return user1;
    }
}
